package org.alvin.i18n.newui;

import com.alibaba.fastjson.JSONObject;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

public class CompairJSON {

    public static void main(String[] args) throws IOException {
        JSONObject src = JSONObject.parseObject(new String(Files.readAllBytes(Paths.get("D:\\merge\\zi18n_v3_new_cn.js"))));
        JSONObject dist = JSONObject.parseObject(new String(Files.readAllBytes(Paths.get("D:\\merge\\zi18n_v3_new_en.js"))));
        JSONObject result = new JSONObject();
        for (String key : src.keySet()) {
            if (dist.containsKey(key)) {
                JSONObject subSrc = src.getJSONObject(key);
                JSONObject subDict = dist.getJSONObject(key);
                JSONObject subResult = new JSONObject();
                for (String subKey : subDict.keySet()) {
                    if (subDict.containsKey(subKey)) {
                        continue;
                    }
                    subResult.put(subKey, subSrc.getString(subKey));
                }
                if (!subResult.isEmpty()) {
                    result.put(key, subResult);
                }
                continue;
            }
            result.put(key, src.getJSONObject(key));
        }
        System.out.println(result);
    }
}
